package com.dimanche.mvvm;

import android.app.Application;

import com.dimanche.library_base.module.IModuleInit;
import com.dimanche.library_base.utils.LogUtils;

import me.goldze.mvvmhabit.crash.CaocConfig;
import me.goldze.mvvmhabit.utils.KLog;

/**
 * author : Dimanche
 * date   : 2021/3/8 16:16
 * desc   :
 * version: 1.0
 */
public class MvvmHabitModuleInit implements IModuleInit {

    private final static String TAG = "MvvmHabitModuleInit";

    @Override
    public boolean onInitAhead(Application application) {
        LogUtils.logi(TAG, "MvvmHabit模块先初始化");
        //是否开启日志打印
        KLog.init(true);
        //配置全局异常崩溃操作
        CaocConfig.Builder.create()
                .backgroundMode(CaocConfig.BACKGROUND_MODE_SILENT) //背景模式,开启沉浸式
                .enabled(true) //是否启动全局异常捕获
                .showErrorDetails(true) //是否显示错误详细信息
                .showRestartButton(true) //是否显示重启按钮
                .trackActivities(true) //是否跟踪Activity
                .minTimeBetweenCrashesMs(2000) //崩溃的间隔时间(毫秒)
                // .errorDrawable(R.mipmap.ic_launcher) //错误图标
                // .restartActivity(LoginActivity.class) //重新启动后的activity
                //.errorActivity(YourCustomErrorActivity.class) //崩溃后的错误activity
                //.eventListener(new YourCustomEventListener()) //崩溃后的错误监听
                .apply();
        return false;
    }

    @Override
    public boolean onInitLow(Application application) {
        LogUtils.logi(TAG, "MvvmHabit模块后初始化");
        return false;
    }
}
